<!-- 竣工决算组件 -->
<template>
    <u-collapse-item ref="settlement" @change="handleChange" :open="show">
        <uni-view slot="title" class="u-page__title">采购订单调整情况</uni-view>
        <view>
            <u-subsection style="margin-bottom: 20rpx;" :list="list" :current="current" @change="tabsChange">
            </u-subsection>
            <view v-for="(item, index) in materialList" :key="index" v-show="current == 0"
                style="padding: 0 12rpx;border-bottom: 1px solid #ccc;margin-bottom: 20rpx;">
                <view style="display: flex;justify-content: space-between;">
                    <view style="background:#efefef;font-size: 32rpx;text-indent: 10rpx;color: #333333">物资编码:
                        {{ item.scategoryCode }}
                    </view>
                    <view style="font-size: 32rpx;color: #108ee9" @click="lookDetail(item, '01')">查看明细</view>
                </view>
                <view style="font-size: 32rpx;color: #333333;width: 87%;margin: 6rpx 0;">物资名称:
                    {{ item.scategoryName }}
                </view>
                <view style="font-size: 32rpx;color: #333333">单价(不含税) : {{ item.price }}</view>
                <view style="font-size: 32rpx;color: #333333;margin: 6rpx 0;">数量 : {{ item.amount }}</view>
            </view>
            <view v-for="(item) in serviceList" :key="item.code" v-show="current == 1"
                style="padding: 0 12rpx;border-bottom: 1px solid #ccc;margin-bottom: 20rpx;">
                <view style="display: flex;justify-content: space-between;">
                    <view
                        style="background:#efefef;font-size: 32rpx;text-indent: 10rpx;color: #333333;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;display: block;">
                        服务编码:
                        {{ item.categoryCode }}
                    </view>
                    <view style="font-size: 32rpx;color: #108ee9" @click="lookDetail(item, '02')">查看明细</view>
                </view>
                <view style="font-size: 32rpx;color: #333333;width: 87%;margin: 6rpx 0;">服务名称:
                    {{ item.categoryName }}
                </view>
                <view style="font-size: 32rpx;color: #333333">合计(不含税) : {{ item.equipSum }}</view>
                <view style="font-size: 32rpx;color: #333333;margin: 6rpx 0;">合计(含税) : {{ item.amt }}</view>
            </view>
            <view style="display: flex;justify-content: center;height: 200rpx;align-items: center;font-size: 32rpx;"
                v-if="(materialList.length === 0 && current == 0) || (serviceList.length === 0 && current == 1)">
                暂无数据
            </view>
        </view>
    </u-collapse-item>
</template>

<script>
export default {
    name: "SettlementDetail",
    props: {
        prjId: {
            type: String,
            default: ''
        }
    },
    data() {
        return {
            show: true,
            list: [
                {
                    name: "物资明细信息",
                },
                {
                    name: "服务明细信息",
                }
            ],
            current: 0,
            materialList: [],
            serviceList: [
            ],
            prjDetails: {
            }
        }
    },
    methods: {
        handleChange() {
            this.show = !this.show
        },
        tabsChange(index) {
            this.current = index;
            if (index === 0) {
                this.getMaterialList()
            } else {
                this.getServiceList()
            }
        },
        lookDetail(item, type) {
            console.log("查看明细", item);
            // 
            // 
            // 物资
            if (type === '01') {
                imp.iWindow.open({ url: `${process.uniEnv.BASE_ZR_URL}/#/inspur/settlement/components/materialDetails?prjId=${encodeURIComponent(JSON.stringify(this.prjId))}` })
                // uni.navigateTo({
                //     url: `/inspur/settlement/components/materialDetails?prjId=${encodeURIComponent(JSON.stringify(this.prjId))}`
                // })
            } else {
                // 服务
                imp.iWindow.open({ url: `${process.uniEnv.BASE_ZR_URL}/#/inspur/settlement/components/serviceDetails?prjId=${encodeURIComponent(JSON.stringify(this.prjId))}`})
                // uni.navigateTo({
                //     url: `/inspur/settlement/components/serviceDetails?prjId=${encodeURIComponent(JSON.stringify(this.prjId))}`
                // })
            }

        },
        async getId() {
            const { data } = await this.$axios.post(`/settlement/api/settle_project/queryAdjustInfo?prjId=${this.prjId}`)
            this.prjDetails = data
            await this.getMaterialList()
        },
        async getMaterialList() {
            const { data } = await this.$axios.get(`/settlement/api/material_adjust/getMaterialAdjustInfo?adjustId=${this.prjDetails.adjId}`)
            this.materialList = data
            this.$nextTick(() => {
                this.$refs.settlement.init();
            });
        },
        async getServiceList() {
            const { data } = await this.$axios.post(`/settlement/api/server_adjust/queryQuantitiesServList?adjustId=${this.prjDetails.adjId}`)
            this.serviceList = data
            this.$nextTick(() => {
                this.$refs.settlement.init();
            });
        }
    },
    async created() {
        this.getId()
    }
}

</script>
<style>
@import "@/common/uView.css";
</style>
<style scoped lang='scss'>
.u-collapse-item {
    background-color: #fff;
}

.content {
    width: calc(100% - 40rpx);
    padding: 0 22rpx;
    color: #333333;
    height: 74rpx;
    margin-bottom: 20rpx;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 32rpx
}
</style>